package com.vf.admin.miaodong.service.impl;

import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.dao.AfterOrderDao;
import com.vf.admin.miaodong.entity.AppMingxiChongzhi;
import com.vf.admin.miaodong.entity.AppOrder;
import com.vf.admin.miaodong.service.AfterOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单
 */
@Service
public class AfterOrderServiceImpl implements AfterOrderService {

    @Autowired
    AfterOrderDao afterOrderDao;

    /**
     * 详情
     */
    @Override
    public AppOrder get(Integer id) {
        return afterOrderDao.get(id);
    }

    /**
     * 添加/修改
     */
    @Override
    public void save(AppOrder appOrder) {
        afterOrderDao.save(appOrder);
    }

    /**
     * 删除
     */
    @Override
    public void del(Integer id) {
        afterOrderDao.del(id);
    }

    /**
     * 综合查询
     * @param map
     * @param bean
     * @return
     */
    @Override
    public List<AppOrder> findList(Map<String, Object> map, SplitPageBean bean) {
        return afterOrderDao.findList(map,bean);
    }

    @Override
    public Double total(Map<String, Object> params) {
        BigDecimal b = BigDecimal.ZERO;
        List<AppMingxiChongzhi> total = afterOrderDao.total(params);
        System.out.println("总数："+total.size());

        for (AppMingxiChongzhi e : total) {
            if (e.getMoney().compareTo(BigDecimal.ZERO) != 0) {
//                BigDecimal divide = e.getMoney().divide(new BigDecimal("100"));
                b = b.add(e.getMoney());
            }
        }
        return b.doubleValue();
    }

    @Override
    public List<AppOrder> getAppOrderV2(Map<String, Object> params) {

        return afterOrderDao.getAppOrderV2(params);
    }
}
